﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class managerFlight : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        
        if (!Page.IsPostBack)
        {
            Calendar1.Visible = false;
           
        }
    }

 

    protected void RequestedDeliveryDateCalendar_SelectionChanged(object sender, EventArgs eventArgs)
    {
        日期.Text = Calendar1.SelectedDate.ToShortDateString();

        // 隐藏日历  
        if (!(日期.Text == "")) {
            Calendar1.Visible = false;
        }

    }

    protected void ListView1_SelectedIndexChanged(object sender, EventArgs e)
    {

    }

    protected void foundflight_Click(object sender, EventArgs e)
    {
        StringBuilder sqlStr = new StringBuilder("SELECT* FROM[flight]");
        List<string> wheres = new List<string>();
        if (日期.Text.Length > 0)
        {
            wheres.Add("[takeoff_time] = '" + 日期.Text + "'");
        }

        if (出发地.Text.Length > 0)
        {
            wheres.Add("([start_place] LIKE '%" + 出发地.Text + "%')");
        }

        if (目的地.Text.Length > 0)
        {
            wheres.Add("([end_place] LIKE '%" + 目的地.Text + "%')");
        }


        //判断用户是否选择了条件
        if (wheres.Count > 0)
        {

            string wh = string.Join(" and ", wheres);
            sqlStr.Append(" where " + wh);
        }


        string cc = sqlStr.ToString();

        showG(cc);

    }
   
    protected void showG(string cc)
    {
        SqlDataSource1.SelectCommand = cc;
        ListView1.DataSourceID = SqlDataSource1.ID;


        //order order = new order();
        //ListView1.DataSource = order.getOrder(日期.Text, 姓名.Text);
        ListView1.DataBind();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Calendar1.Visible = !Calendar1.Visible;
    }
}